package com.huadao.cart_ccs.modle;

import com.huadao.cart_ccs.base.BaseSerialPortModel;
import com.huadao.cart_ccs.common.ByteUtils;
import com.huadao.cart_ccs.data.bo.CommandWord;
import com.huadao.cart_ccs.data.bo.O2BO;
import com.huadao.cart_ccs.data.bo.Protocol;

public class O2Modle extends BaseSerialPortModel {
    private String TAG="O2";

    public void readO2(){
        Protocol params= ByteUtils.generateProtocol(CommandWord.read,new byte[]{O2BO.ModularType_Atmosphere,O2BO.Atmosphere_O2,O2BO.read},null);
        serialPortRequest(params);
    }

    public void setO2(double O2){
        byte[] O2Bytes=ByteUtils.int2bytesLG(2, (int) (O2*100));
        Protocol params= ByteUtils.generateProtocol(CommandWord.write,new byte[]{O2BO.ModularType_Atmosphere,O2BO.Atmosphere_O2,O2BO.write},O2Bytes);
        serialPortRequest(params);
    }

    public void closeO2() {
        Protocol params= ByteUtils.generateProtocol(CommandWord.write,new byte[]{O2BO.ModularType_Atmosphere,O2BO.Atmosphere_O2,O2BO.stop},null);
        serialPortRequest(params);
    }
}
